﻿namespace ResumableDownload.View.Converters
{
    using System;
    using System.Globalization;
    using System.Windows;
    using System.Windows.Data;
    using WP7Contrib.Services.DownloadManager;

    public sealed class FileRequestStateToColourConverter : IValueConverter
    {
        public readonly string StatusFormat = "Status: {0}";

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || value == DependencyProperty.UnsetValue)
            {
                return DependencyProperty.UnsetValue;
            }

            if ((FileRequestState)value == FileRequestState.Completed)
            {
                return "LightGreen";
            }

            if ((FileRequestState)value == FileRequestState.Started)
            {
                return "Yellow";
            }

            if ((FileRequestState)value == FileRequestState.Failed)
            {
                return "Red";
            }

            return "White";
        }
        
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }
    }
}
